package leetcode.code0883;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int projectionArea(int[][] grid) {
		int ans = 0;
		int m = grid.length, n = grid[0].length;
		int[] max = new int[n];// y面
		for (int i = 0; i < m; i++) {
			int h = Integer.MIN_VALUE;
			for (int j = 0; j < n; j++) {
				int cur = grid[i][j];
				if (cur != 0) {
					ans += 1;// x面一个
				}
				h = Math.max(h, cur);
				max[j] = Math.max(max[j], cur);
			}
			ans += h;// z面
		}
		for (int i = 0; i < max.length; i++) {
			ans += max[i];
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
